package edu.ptit.jad.preprocess.analysis;

import java.util.HashMap;
import java.util.List;

import edu.ptit.jad.data.DataAccess;
import edu.ptit.jad.exception.AdException;

public class VietnameseSynonymEngine implements SynonymEngine {
	private static HashMap<String, String[]> map = new HashMap<String, String[]>();

	static {

		try {
			List<String> synonymWords = DataAccess.getInstance()
					.getSynonymWords();

			for (String synonym : synonymWords) {

				String[] splits = synonym.split("=>");

				map.put(splits[0], new String[] { splits[1] });
			}

			// map.put("nghàn", new String[] { "nghìn" });
			// map.put("đ", new String[] { "vnđ" });

		} catch (AdException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public String[] getSynonyms(String s) {
		return map.get(s);
	}

	public String getSynonymsTerm(String s) {

		if (!map.containsKey(s))
			return s;
		else {
			String[] vals = map.get(s);
			return vals[0];
		}

	}
}
